package com.shell.provider;

import com.shell.bee.base.utils.StringUtil;
import com.shell.governor.security.user.service.PubSecurityService;
import com.shell.governor.security.user.vo.RuleCheckMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PubSecurityRuleProvider {
	@Autowired
	private PubSecurityService pubSecurityService;

	@RequestMapping({ "/pubSecurityRule/checkSecurityRule" })
	public RuleCheckMsg checkSecurityRule(@RequestParam("userId") String userId,
			@RequestParam("password") String password, @RequestParam("securityType") String securityType,
			@RequestParam("checkExpire") boolean checkExpire) {
		RuleCheckMsg msg = new RuleCheckMsg();
		msg.setCheckState(false);
		msg.setType(securityType);
		if (StringUtil.emptyAndNull(userId)) {
			msg.setCheckMsg("����ID����,������������");
			return msg;
		}
		if ((StringUtil.emptyAndNull(securityType))
				|| ((!securityType.equals("login")) && (!securityType.equals("pay")))) {
			msg.setCheckMsg("������������");
			return msg;
		}
		if (StringUtil.emptyAndNull(password)) {
			msg.setCheckMsg("����������������");
			return msg;
		}
		return this.pubSecurityService.checkSecurityRule(userId, password, securityType, checkExpire);
	}
}
